#include <cv.h>

#ifndef _OPENCV_HELPER_H_
#define _OPENCV_HELPER_H_

template<class T> class ImgWrap
{
 private:
  IplImage *_img;

 public:
  ImgWrap(IplImage *img=0) { _img = img; }

  ~ImgWrap() { _img = 0; }

  void operator=(IplImage *img) { _img = img; }
  
  IplImage* operator->() const { return _img; }

  inline T *operator[] (const int rowIndx) {
    return ((T *)(_img->imageData + rowIndx*_img->widthStep));
  }
};

typedef struct {
  unsigned char c0, c1, c2;
} Pixel8u3c;

typedef struct {
  unsigned char c0;
} Pixel8u1c;

typedef ImgWrap<Pixel8u3c>  ImgWrap8u3c;
typedef ImgWrap<Pixel8u1c>  ImgWrap8u1c;

#endif
